package Week04.Day01.PuKe01;

import java.util.ArrayList;
import java.util.Collections;

public class DouDiZhuGame {
    /**
     * 将54张扑克牌初始化并放在对应的集合里面
     */
    ArrayList<String> list = new ArrayList<>();
    public void init() {
        String[] colors = {"黑桃", "红桃", "方块", "梅花" };
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2" };
        for (int i = 0; i < number.length; i++) {
            for (int j = 0; j < colors.length; j++) {
                list.add(colors[j]+number[i]);
            }
        }
        list.add("小王");
        list.add("大王");
    }
    /**
     * 洗牌
     */
    public void xiPai(){
        Collections.shuffle(list);
    }
    /**
     * 发牌
     */
    public void send() {
        ArrayList<String> player1 = new ArrayList(list.subList(0,17));
        ArrayList<String> player2 = new ArrayList(list.subList(17,34));
        ArrayList<String> player3 = new ArrayList(list.subList(34,51));
        ArrayList<String> card = new ArrayList(list.subList(51,54));
        System.out.println("玩家1  " + player1 );
        System.out.println("玩家2  "+ player2);
        System.out.println("玩家3  "+ player3);
        System.out.println("底牌  " + card);
    }
    public static void main(String[] args) {
        DouDiZhuGame start = new DouDiZhuGame();
        start.init();
        start.xiPai();
        start.send();
    }
}
